package com.github.admin.edu.security.jwt.server.configuration;

import com.github.admin.edu.security.jwt.server.interceptor.ClientAuthInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Create by IntelliJ IDEA
 * 用户：王建
 * 日期：2018-7-19
 */
@Configuration
public class JWTConfiguration  implements WebMvcConfigurer {

    public void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(getClientAuthInterceptor())
                .addPathPatterns("/rest/api/oauth/**")
                .excludePathPatterns("/rest/api/oauth/token","/rest/api/oauth/authentication");
    }

    @Bean
    public ClientAuthInterceptor getClientAuthInterceptor(){
        return new ClientAuthInterceptor();
    }

}
